package com.ruoyi.quartz.task;

import com.ruoyi.common.utils.applets.AppletsUtils;
import com.ruoyi.system.service.ISysConfigService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * [刷新小程序ACCESS_TOKEN]定时任务
 *
 * @author KevenPotter
 * @date 2024-04-28 11:32:25
 */
@Component("refreshAppletsAccessTokenTask")
@Slf4j
@AllArgsConstructor
public class RefreshAppletsAccessTokenTask {

    private final ISysConfigService sysConfigService;

    public void refreshAppletsAccessTokenTask() {
        String appletsAppId = sysConfigService.selectConfigByKey("applets_app_id");
        String appletsAppSecret = sysConfigService.selectConfigByKey("applets_app_secret");
        log.info("Enter refreshAppletsAccessTokenTask......");
        String appletsAccessToken = AppletsUtils.refreshAccessToken(appletsAppId, appletsAppSecret);
        log.info("applets_access_token: {}", appletsAccessToken);
        log.info("Exit  refreshAppletsAccessTokenTask......");
    }
}
